package com.bdqn.spark.chapter05.value

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark01_RDD_Operator_Transform_Test {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
      .setMaster("local[*]")
      .setAppName("practise")
    val sc: SparkContext = new SparkContext(conf)

    val fileRDD: RDD[String] = sc.textFile("input/apache.log")

    val pathRDD: RDD[String] = fileRDD.map(
      line => {
        val fields: Array[String] = line.split(" ")

        fields(fields.length - 1)
      }
    )

    pathRDD.collect.foreach(println)
    sc.stop()
  }
}
